﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataModel;

namespace SchoolDataLayer
{
   public class DLImages
    {
       public int SaveImage(Images _image)
       {
           using (SqlConnection conn = DBConn.GetConnectionString())
           {
               using (SqlCommand cmd = conn.CreateCommand())
               {
                   cmd.CommandText = "ProcSaveImage";
                   cmd.CommandType = CommandType.StoredProcedure;
                   cmd.Parameters.AddWithValue("@FileName", _image.PhotoName);
                   cmd.Parameters.AddWithValue("@FilePath", _image.PhotoPath);
                   cmd.Parameters.AddWithValue("@uploadedon", DateTime.Now);
                   int id= Convert.ToInt32(cmd.ExecuteScalar().ToString());
                   return id;
               }
           }

       }
    }
}
